//
//  Ball.m
//  BeatPong
//
//  Created by Gabriel Lumbi on 12-08-16.
//
//

#import "Ball.h"

#import "cocos2d.h"

@implementation Ball

#pragma mark Properties

@synthesize velocity;
@synthesize radius;
@synthesize color;

#pragma mark Constants

#pragma mark -

#pragma mark Life Cycle

-(id) init
{
    if(self = [super init])
    {
        [self scheduleUpdate];
        velocity = CGPointZero;
        radius = 10.f;
        color = ccc4f(1, 1, 1, 1);
    }
    return self;
}

-(void) dealloc
{
    [super dealloc];
}

#pragma mark -

#pragma mark Draw

-(void) draw
{
    [super draw];
    
    ccDrawColor4F(color.r, color.g, color.b, color.a);
    ccDrawCircle([self convertToNodeSpace:self.position],
                 self.radius,
                 0,
                 30,
                 NO);
}

#pragma mark -

#pragma mark Update

-(void) update: (ccTime)deltaTime
{
    self.position = ccp(self.position.x + self.velocity.x * deltaTime, self.position.y + self.velocity.y * deltaTime);
}

@end